//   @Author: zeng_ze
//   @date: 2020-1-6
//   @Description: 定时任务接口

import request from '@/utils/request'

// job-info 任务管理 接口
//查看任务主页信息
export function infoTasks (jobGroup) {
  return request({
    url: '/sys-job-admin/jobinfo/index',
    method: 'get',
    params: {
      jobGroup
    }
  })
}
//查看任务分页列表
export function getTasks (author, jobGroup, jobDesc, executorHandler, length, start, triggerStatus) {
  return request({
    url: '/sys-job-admin/jobinfo/job/pageList',
    method: 'get',
    params: {
      author,
      jobGroup,
      jobDesc,
      executorHandler,
      length,
      start,
      triggerStatus
    }
  })
}
//编辑任务信息
export function editTasks (data) {
  return request({
    url: '/sys-job-admin/jobinfo/job',
    method: 'put',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
//删除任务 根据id
export function deleteTasks (id) {
  return request({
    url: '/sys-job-admin/jobinfo/job',
    method: 'delete',
    params: {
      id
    }
  })
}
//添加任务
export function addTasks (data) {
  return request({
    url: '/sys-job-admin/jobinfo/job',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
//启动任务
export function startTasks (id) {
  return request({
    url: '/sys-job-admin/jobinfo/job/start',
    method: 'get',
    params: {
      id
    }
  })
}
//任务执行一次
export function triggerTasks (executorParam, id) {
  return request({
    url: '/sys-job-admin/jobinfo/job/trigger',
    method: 'get',
    params: {
      executorParam,
      id
    }
  })
}
//停止任务
export function stopTasks (id) {
  return request({
    url: '/sys-job-admin/jobinfo/job/stop',
    method: 'get',
    params: {
      id
    }
  })
}
// job-group 执行器管理 接口
//查看任务执行器主页数据
export function getExecutor () {
  return request({
    url: '/sys-job-admin/jobgroup/index',
    method: 'get',
  })
}
//删除执行器
export function deleteExecutor (id) {
  return request({
    url: '/sys-job-admin/jobgroup/executor',
    method: 'delete',
    params: {
      id
    }
  })
}
//添加执行器
export function addExecutor (data) {
  return request({
    url: '/sys-job-admin/jobgroup/executor',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
//编辑执行器
export function editExecutor (data) {
  return request({
    url: '/sys-job-admin/jobgroup/executor',
    method: 'put',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
// 调度日志 接口